/*
Date:20210822 21:32PM
key:线程交替打印那个一定要有sleep方法在，否则不输出。
*/
package main
import (
        "fmt"
		"time"
		"sync"
)
var (count int
	lock sync.Mutex)

type sig struct{
	Data int
}
var(
	lock1 sync.Mutex
	q *sig
)
func NewSig(num int)(*sig){
	if(q==nil){
		lock1.Lock()
		if(q==nil){
			q=&sig{Data:10}
		}
		lock1.Unlock()
	}
	return q
}
func Print(q *sig){
	fmt.Println(q.Data)
}
func sayA() {cnt:=0
        for cnt < 3 {
			
                if(count==0){
					fmt.Println("A",count)
					count=1
					cnt++
				}
                
        }
}
func sayB() {cnt:=0
	for cnt < 3 {
		
			if(count==1){
				
				fmt.Println("B",count)
				count=2
				cnt++
			}
			
	}
}
func sayC() {cnt:=0
	for cnt < 3 {
			if(count==2){
				fmt.Println("C",count)
				count=0
				cnt++
			}
			
	}
}

func main() {
	go sayB()
	go sayA()
	go sayC()
	time.Sleep(time.Second*1)
}